<template>
	<view>
		<form @submit="onSubmit" @reset="">
			<view class="form-item">
				<text>服务类型</text>
				<view>
					<radio-group name="type" @change="radioChange">
						<label class="radio">
							<radio value="1" checked="true" />
							<text>退货</text>
						</label>
						<label class="radio">
							<radio value="2" />
							<text>换货</text>
						</label>
					</radio-group>
				</view>
			</view>

			<view class="form-item">
				<text>提交数量</text>
				<view><my-input-number :count="quantity" @changeNumberEvent="getOperator"></my-input-number></view>
			</view>

			<view class="form-item">
				<text>问题描述</text>
				<textarea placeholder-style="color: #9a9a9a" placeholder="请输入问题描述" v-model="message" />
			</view>

			<view class="form-button"><button type="primary" @click="serviceAddSubmit">提交售后</button></view>
		</form>
	</view>
</template>

<script>
import myInputNumber from '@/components/my-input-number/my-input-number.vue';

export default {
	components: { myInputNumber },

	data() {
		return {
			order_goods_id: 0,
			type: 1,
			quantity: 1,
			message: ''
		};
	},
	onLoad(options) {
		this.order_goods_id = options.order_goods_id
	},
	methods: {
		
		serviceAddSubmit(){
			
			
			this.$http.post('/shop.order/service_create', {
				order_goods_id: this.order_goods_id,
				type: this.type,
				quantity: this.quantity,
				message: this.message,
			}).then(res => {
				
				
				if(res.data.data > 0){
					
					uni.showToast({
						title: '售后已提交，我们会尽快处理'
					})
					//uni.navigateBack()
					
				}			 
			   
			   
			});
			
		},
		
		radioChange: function(evt) {
			for (let i = 0; i < this.items.length; i++) {
				if (this.items[i].value === evt.target.value) {
					this.type = i;
					break;
				}
			}
		},

		getOperator(op) {
			if (op === 'plus') {
				this.quantity++;
			} else {
				if (this.quantity > 1) {
					this.quantity--;
				}
			}
		}
	}
};
</script>

<style lang="scss">
	
	.form-item{
		
		.radio{
			margin-right: 20rpx;
		}
		
	}
	
</style>
